<?php 
echo $this->Form->create("Payroll", array('action' => 'process_mail'));
echo $this->Form->hidden("Payroll.batch_list_id", array('value' => $batchData['BatchList']['id']));
?>
<table cellpadding="5">
    <tr><th style="text-align: right;"><?php echo __('FROM')?> :</th><td><?php echo $usersData[$current_user_id];?> Role: <?php echo $userRole[$current_user_id];?></td></tr>
    <tr>
        <th style="text-align: right; vertical-align: top;"><?php echo __('TO')?> :</th>
        <td>
            <?php 
                $toUser = $ccUser = $allUser = array();
                if(!empty($userAttachedToUnit)){
                    foreach($userAttachedToUnit as $userToUnit){
                        if(!in_array($userToUnit, $userOnLeave)){
                            $toUser[] = $usersData[$userToUnit]." (Role: ".$userRole[$userToUnit].')';
                        } else{
                            //$ccUser[] = $usersData[$userToUnit].' (Role: '.$userRole[$userToUnit].') On Leave';
                            $toUser[] = $usersData[$userToUnit].' (Role: '.$userRole[$userToUnit].') On Leave';
                        }
                        $allUser[] = $usersData[$userToUnit];
                    }
                }
                echo implode('<br/>', $toUser);
            ?>
        </td>
    </tr>
    <!-- <tr><th style="text-align: right; vertical-align: top;"><?php //echo __('CC')?> :</th><td><?php //echo (!empty($ccUser)) ? implode(', ', $ccUser) : __('NONE');?></td></tr>-->
    <tr><th style="text-align: right;"><?php echo __('SUBJECT')?> :</th><td>Part time payroll approval status</td></tr>
    <tr><th style="text-align: right;"><?php echo __('CONTENT')?> :</th><td><?php echo __('STATUS'); ?> : <?php echo ($batchData['BatchList']['approved_by'] == 0) ? __('YET_TO_APPROVE') : __('APPROVED');?></td></tr>
    <tr><th style="text-align: right;">&nbsp;</th><td><?php echo __('BATCH_DATE'); ?> : <?php echo date('M j, Y', strtotime($batchData['BatchList']['prepared_date']));?></td></tr>
    <tr><th style="text-align: right;">&nbsp;</th><td><?php echo __('SERVICE_UNIT'); ?> : <?php echo $batchData['BatchList']['unit_code']; ?></td></tr>
    <!--<tr>
        <th style="text-align: right;">&nbsp;</th>
        <td>
            <table style="width:100%">
                <tr>
                    <th style="width:33%; text-align: left;"><?php //echo __('CREATED'); ?></th>
                    <th style="width:33%; text-align: left;"><?php //echo __('VERIFIED'); ?></th>
                    <th style="width:33%; text-align: left;"><?php //echo __('APPROVED'); ?></th>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <th style="text-align: right;"><?php //echo __('BY')?></th>
        <td>
            <table style="width:100%">
                <tr>
                    <td style="width:33%"><?php //echo ($batchData['BatchList']['prepared_by']) ? $usersData[$batchData['BatchList']['prepared_by']] : '--' ?></td>
                    <td style="width:33%"><?php //echo ($batchData['BatchList']['verified_by']) ? $usersData[$batchData['BatchList']['verified_by']] : '--' ?></td>
                    <td style="width:33%"><?php //echo ($batchData['BatchList']['approved_by']) ? $usersData[$batchData['BatchList']['approved_by']] : '--' ?></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <th style="text-align: right;"><?php //echo __('DATE')?></th>
        <td>
            <table style="width:100%">
                <tr>
                    <td style="width:33%"><?php //echo date('M j, Y', strtotime($batchData['BatchList']['prepared_date'])); ?></td>
                    <td style="width:33%"><?php //echo ($batchData['BatchList']['verified_date'] != '0000-00-00') ? date('M j, Y', strtotime($batchData['BatchList']['verified_date'])) :  __('YET_TO_VERIFY'); ?></td>
                    <td style="width:33%"><?php //echo ($batchData['BatchList']['approved_date'] != '0000-00-00') ? date('M j, Y', strtotime($batchData['BatchList']['approved_date'])) :  __('YET_TO_APPROVE'); ?></td>
                </tr>
            </table>
        </td>
    </tr>-->

    <tr>
        <th>&nbsp;</th>
        <th style="text-align: left;"><?php echo __('AUTHORIZED_STAFF');?></th>
    </tr>
    <tr>
        <th style="text-align: right;">&nbsp;</th>
        <td><?php echo implode(', ', $allUser);?></td>
    </tr>
    
    <tr>
        <th>&nbsp;</th>
        <th style="text-align: left;"><?php echo __('STAFF_ON_LEAVE');?></th>
    </tr>
    <tr>
        <th style="text-align: right;">&nbsp;</th>
        <td><?php echo implode(', ', $ccUser);?></td>
    </tr>
    <tr>
        <th style="text-align: right;"><?php echo __('REMARK');?></th>
        <td><?php echo $this->Form->input('Payroll.remark', array('type' => 'textarea', 'label' => FALSE, 'style' =>'resize:none;'));?></td>
    </tr>
    <tr>
        <td style="text-align: center;" colspan="2">
            <?php 
                echo $this->Form->submit(__('SEND', true), array(
                    "class" => "button", 
                    'label' => false, 
                    'div' => false,
                    'onclick'=>'return confirm("Are you sure to Send Email?")'
                ));
                echo '<div class="buttonEnding"></div>';
            ?>
        </td>
    </tr>
</table>
<?php echo $this->Form->end(); ?>
